#!/usr/bin/env python
# -*- coding:UTF-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf8')

#import pyttsx

#engine = pyttsx.init()
#engine.say("Sally sells seashells by the seashore.")
#engine.say('The quick brown fox jumped over the lazy dog.')


# #更换发音人声音
# voices = engine.getProperty('voices')
# for voice in voices:
#     print voice.id
#
# engine.setProperty('voice', 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\MS-Lili-2052-20-DSK')
#
#
# #语速控制
# rate = engine.getProperty('rate')
# engine.setProperty('rate', rate-50)
#
# #音量控制
# rate = engine.getProperty('volume')
# engine.setProperty('volume', rate-0.25)
#
#
# engine.setProperty('rate', 140)
# #engine.setProperty('voices', 'english')
#
# engine.say("python is the best lib.")
# engine.say(u"人生苦短，周益你要好好学会python")
#
# for i in range(5, 0, -1):
#     engine.say(i)
# engine.runAndWait()

import pyttsx

engine = pyttsx.init()
engine.setProperty('rate', 140)
engine.setProperty('volume', 1)
def SpeekText(content):
    print content
    engine.say(content)
    #print engine.getProperty('rate')
    #print engine.getProperty('volume')
    engine.runAndWait()
    return '{"code":1,"msg":"ok"}'

def SetSpeekRate(rate):
    engine.setProperty('rate', 140)
    return '{"code":1,"msg":"ok"}'

def SetSpeekVolume(volume):
    engine.setProperty('volume', 0.50)
    return '{"code":1,"msg":"ok"}'
